package com.duoduo.algs4.util;

import static org.junit.Assert.assertTrue;
import edu.princeton.cs.introcs.StdOut;

public class Counter {
	private int N;
	private String id;

	public Counter(String id) {
		this.id = id;
	}

	public void increment() {
		N++;
	}

	public int totally() {
		return N;
	}

	public String toString() {
		return String.format("%s:共%d次", id,N);
	}
	public static void main(String[] args) {
		Counter head = new Counter("测试计数器");
		for (int i = 0; i < 10; i++) {
			head.increment();
		}
		StdOut.println(head);
		assert head.totally() == 10;

	}
}